﻿
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
    <style type="text/css">
    <!--
    
    #edit
    {
        opacity: 0.8;
    }   
    #edit:hover
    {
        opacity: 1;
    }
    #del
    {
        opacity: 0.8;
    }
    #del:hover
    {
        opacity: 1;
    }   
    #check
    {
        opacity: 0.8;
    }
    #check:hover
    {
        opacity: 1;
    }
        
    -->
    </style>
    <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
    	<script src="ckeditor/_samples/sample.js" type="text/javascript"></script>
    	<link href="ckeditor/_samples/sample.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    
    
          <?php
                    
    				include("code/DataProvider.php");
    				$query=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
                            FROM DonDatHang ddh, chitietddh ct, nguoidung nd, sanpham sp
                            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP ORDER BY ddh.NgayDat DESC";
    				$result=DataProvider::executeQuery($query);
                    
                    
                    
    				if($result)
    				{
            ?>
              
                <h2 style="color: blue; text-align: center;">DANH SÁCH ĐƠN ĐẶT HÀNG</h2>
                <form action="#" name="search_sp" method="GET"  >
                        <i><u>&nbsp;&nbsp;Tìm Kiếm Nhanh&nbsp;&nbsp;</u></i><br />
                        <input type="text" name="txtSearchHD" class="search_input"  />
                        <a href = "pSearchSP.php"><input type="image" class="search_submit" src="images/search.png" /></a>
            
                    <br />
                    <br />
                    &nbsp;Mã đơn đặt hàng<input type="radio" name="search" id="search" value="1" checked="checked" /> |
                    &nbsp;&nbsp;Mã SP<input type="radio" name="search" id="search" value="2"  /> |
                    &nbsp;&nbsp;Tên SP<input type="radio" name="search" id="search" value="3"  /> |
                    &nbsp;&nbsp;Tên người đăng <input type="radio" name="search" id="search" value="4"  /> |
                    &nbsp;&nbsp;Tổng tiền<input type="radio" name="search" id="search" value="5"  />
                </form> 
                <hr /><br /> 
        <table border="1" cellspacing="0" style=" text-align: center; font-size: 10px;">
        	<tr style="height: 50px; color: white; background: #555;">
                <td align="center" height="30px" width="100px">Mã đơn đặt hàng</td>
                <td align="center" height="30px" width="100px">Mã sản phẩm</td>
                <td align="center" height="30px" width="100px">Tên sản phẩm</td>
                <td align="center" height="30px" width="100px">Giá sản phẩm</td>
                <td align="center" height="30px" width="100px">Số lượng</td>
                <td align="center" height="30px" width="100px">Ngày đặt</td>
                <td align="center" height="30px" width="100px">Người mua</td>
                <td align="center" height="30px" width="100px">Người bán</td>
                <td align="center" height="30px" width="100px">Tổng tiền</td>
                <td align="center" height="30px" width="120px">Xóa ( theo Mã ĐĐH )</td>
            </tr><?php
            while ($row=mysql_fetch_array($result))
    			{?>
            <tr>
                <td align="center" ><?php echo $row['MaDDH']; ?></td>
                <td align="center" ><?php echo $row['MaSP']; ?></td>
                <td align="center" ><?php echo $row['TenSP']; ?></td>
                <td align="center" ><?php echo $row['GiaCa']; ?></td>
                <td align="center" ><?php echo $row['SoLuong']; ?></td>
                <td align="center" ><?php echo $row['NgayDat']; ?></td>
                <td align="center" ><?php echo $row['TenDangNhap']; ?></td>
                <td align="center" >
                                    <?php
                                            $query1=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
                            FROM nguoidung nd, sanpham sp, chitietddh ct, DonDatHang ddh
                            WHERE ddh.MaDDH = ct.MaDDH AND sp.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND sp.MaSP = '".$row['MaSP']."' ORDER BY ddh.NgayDat DESC";
                    $result1 = DataProvider::executeQuery($query1);
                    $row1=mysql_fetch_array($result1);
                                            if (($row1['MaSP'] == $row['MaSP']) /*&& ($row1['TongTien'] == $row['TongTien']) && ($row1['GiaCa'] == $row['GiaCa']) */ )
                                            { 
                                                echo $row1['TenDangNhap'];
                                            }
                                    ?>
                </td>
                <td align="center" ><?php echo $row['TongTien']; ?></td>
                <td align="center" >
                    <a href="admin.php?act=15&id=<?php echo $row['MaDDH']; ?>">
                        <img id="edit" src="images/delete-icon.png" height="25" width="25"/>   
                    </a>
                </td>
            </tr><?php } ?>
    	</table>	<?php }
    				
    		  ?> 
    
    
    
    </body>
</html>

